<?php
#### START AUTOCODE
################################################################################
#  Lumine - Database Mapping for PHP
#  Copyright (C) 2005  Hugo Ferreira da Silva
#  
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>
################################################################################
/**
 * Classe generada para a tabela "vendas"
 * in 2014-02-24
 * @author Hugo Ferreira da Silva
 * @link http://www.hufersil.com.br/lumine
 * @package dao_orm
 *
 */

class Vendas extends Lumine_Base {

    // sobrecarga
    protected $_tablename = 'vendas';
    protected $_package   = 'dao_orm';
    
    
    public $codigoVenda;
    public $codigoCliente;
    public $codigoLoja;
    public $codigoUsuario;
    public $dataVenda;
    public $dataEvento;
    public $entrada;
    public $parcelas;
    public $total;
    public $semana;
    public $situacao;
    public $brindeVenda;
    public $tipoVenda;
    public $observacao;
    public $codigoUltimoUsuario;
    public $datareg;
    public $movimentacoes = array();
    public $vendaacessorios = array();
    public $vendaprodutos = array();
    
    
    
    /**
     * Inicia os valores da classe
     * @author Hugo Ferreira da Silva
     * @return void
     */
    protected function _initialize()
    {
        
        
        # nome_do_membro, nome_da_coluna, tipo, comprimento, opcoes
        
        $this->_addField('codigoVenda', 'CODIGO_VENDA', 'int', 11, array('primary' => true, 'notnull' => true, 'autoincrement' => true));
        $this->_addField('codigoCliente', 'CODIGO_CLIENTE', 'int', 11, array('notnull' => true, 'foreign' => '1', 'onUpdate' => 'CASCADE', 'onDelete' => 'RESTRICT', 'linkOn' => 'codigoCliente', 'class' => 'Clientes'));
        $this->_addField('codigoLoja', 'CODIGO_LOJA', 'int', 11, array('notnull' => true, 'foreign' => '1', 'onUpdate' => 'CASCADE', 'onDelete' => 'RESTRICT', 'linkOn' => 'codigoLoja', 'class' => 'Lojas'));
        $this->_addField('codigoUsuario', 'CODIGO_USUARIO', 'int', 11, array('notnull' => true, 'foreign' => '1', 'onUpdate' => 'CASCADE', 'onDelete' => 'RESTRICT', 'linkOn' => 'codigoUsuario', 'class' => 'SisUsuarios'));
        $this->_addField('dataVenda', 'DATA_VENDA', 'date', null, array());
        $this->_addField('dataEvento', 'DATA_EVENTO', 'date', null, array());
        $this->_addField('entrada', 'ENTRADA', 'float', null, array());
        $this->_addField('parcelas', 'PARCELAS', 'int', 11, array());
        $this->_addField('total', 'TOTAL', 'float', null, array('notnull' => true));
        $this->_addField('semana', 'SEMANA', 'int', 11, array());
        $this->_addField('situacao', 'SITUACAO', 'int', 2, array());
        $this->_addField('brindeVenda', 'BRINDE_VENDA', 'int', 11, array());
        $this->_addField('tipoVenda', 'TIPO_VENDA', 'int', 1, array());
        $this->_addField('observacao', 'OBSERVACAO', 'text', 65535, array());
        $this->_addField('codigoUltimoUsuario', 'CODIGO_ULTIMO_USUARIO', 'int', 11, array());
        $this->_addField('datareg', 'DATAREG', 'date', null, array());

        
        $this->_addForeignRelation('movimentacoes', self::ONE_TO_MANY, 'Movimentacao', 'codigoVenda', null, null, null);
        $this->_addForeignRelation('vendaacessorios', self::ONE_TO_MANY, 'VendaAcessorios', 'codigoVenda', null, null, null);
        $this->_addForeignRelation('vendaprodutos', self::ONE_TO_MANY, 'VendaProdutos', 'codigoVenda', null, null, null);
    }

    /**
     * Recupera um objeto estaticamente
     * @author Hugo Ferreira da Silva
     * @return Vendas
     */
    public static function staticGet($pk, $pkValue = null)
    {
        $obj = new Vendas;
        $obj->get($pk, $pkValue);
        return $obj;
    }

	/**
	 * chama o destrutor pai
	 *
	 */
	function __destruct()
	{
		parent::__destruct();
	}
	
    #------------------------------------------------------#
    # Coloque todos os metodos personalizados abaixo de    #
    # END AUTOCODE                                         #
    #------------------------------------------------------#
    #### END AUTOCODE


}
